GH-37004: [C++][Python] Fix dropped child data when viewing/casting e… - #50502
Merged
pitrou merged 1 commit intoJul 22, 2026
Merged
Conversation
…ting extension types with nested storage
connorsimms
marked this pull request as ready for review
July 14, 2026 19:14
connorsimms
requested review from
AlenkaF,
pitrou,
raulcd and
rok
as code owners
July 14, 2026 19:14
Member
|
For the record, I wouldn't call this a critical fix, more of a regular bug, but the boundary can be a bit fuzzy. |
pitrou
approved these changes
Jul 22, 2026
pitrou
left a comment
Member
There was a problem hiding this comment.
This PR looks good to me. Thank you @connorsimms !
|
After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 450b793. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 6 possible false positives for unstable benchmarks that are known to sometimes produce them. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
table.cast(table.schema)errored or segfaulted when the schema contained a struct with an extension-typed field whose storage is a list.This cast takes a zero-copy view, and
ViewDataImpl::MakeDataViewfound children usingtype->fields(), which is never populated for extension types since their structure is instorage_type(). The same issue exists inAccumulateLayouts. The storage's child data gets dropped and leaves an invalid array that downstream code throws/crashes on.This bug is similar to #37669, except that the fix for #37669 addressed casting to an extension with nested storage but not this particular struct-wrapped view path.
What changes are included in this PR?
cpp/src/arrow/array/data.cc-AccumulateLayoutsandViewDataImpl::MakeDataViewnow recurse intostorage_type()->fields()forExtensionType, instead of the extension type's emptyfields().cpp/src/arrow/array/array_view_test.ccpython/pyarrow/tests/test_extension_type.pyAre these changes tested?
Yes,
cpp/src/arrow/array/array_view_test.cc- Two tests for viewing an extension array with nested storage for fixed-size and variable-size lists.python/pyarrow/tests/test_extension_type.py- A test casting a table / struct containing an extension type with list-based storage to its own schema.Are there any user-facing changes?
No API changes. Operations that previously raised errors or crashed relating to casting/viewing a struct or table with an extension type with nested storage now succeed.